package cjlu.ea.h.service.impl;

import cjlu.ea.h.entity.SUser;
import cjlu.ea.h.mapper.SUserMapper;
import cjlu.ea.h.service.SUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 学生账号信息 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-04-29
 */
@Service
@Slf4j
public class SUserServiceImpl extends ServiceImpl<SUserMapper, SUser> implements SUserService {

    @Autowired
    RedisTemplate redisTemplate;


    @Override
    public String getUserRoles(String token) {
        String role = (String)redisTemplate.opsForValue().get(token);
        log.info("获取到权限为:{}",role);
        return role;
    }

    @Override
    public String getToken(HttpServletRequest request) {
        String token = request.getHeader("token");
        return token;
    }
}
